doc.low <- tm_map(doc.low, removeWords, c("medicare", "health", "program", "managed", "patient", "physician", "plan"))
# Remove punctuations
doc.low <- tm_map(doc.low, removePunctuation)
# Eliminate extra white spaces
doc.low <- tm_map(doc.low, stripWhitespace)
# Text stemming
doc.low <- tm_map(doc.low, stemDocument)
# specify your stopwords as a character vector
doc.low <- tm_map(doc.low, removeWords, c("manag", "physician"))
dtm.low <- TermDocumentMatrix(doc.low)
m.low <- as.matrix(dtm.low)
v.low <- sort(rowSums(m.low),decreasing=TRUE)
d.low <- data.frame(word = names(v.low),freq=v.low)
wordcloud(words = d.low$word, freq = d.low$freq, min.freq = 1,
max.words=50, random.order=FALSE, rot.per=0.35,
colors=brewer.pal(8, "Dark2"))
head(d.low, 10)
text.low <- readLines(file.choose())
doc.low <- Corpus(VectorSource(text.low))
# inspect(doc.low)
toSpace <- content_transformer(function (x , pattern ) gsub(pattern, " ", x))
doc.low <- tm_map(doc.low, toSpace, "/")
doc.low <- tm_map(doc.low, toSpace, "@")
doc.low <- tm_map(doc.low, toSpace, "\\|")
# Convert the text to lower case
doc.low <- tm_map(doc.low, content_transformer(tolower))
# Remove numbers
doc.low <- tm_map(doc.low, removeNumbers)
# Remove english common stopwords
doc.low <- tm_map(doc.low, removeWords, stopwords("english"))
doc.low <- tm_map(doc.low, removePunctuation)
# Eliminate extra white spaces
doc.low <- tm_map(doc.low, stripWhitespace)
dtm.low <- TermDocumentMatrix(doc.low)
m.low <- as.matrix(dtm.low)
v.low <- sort(rowSums(m.low),decreasing=TRUE)
d.low <- data.frame(word = names(v.low),freq=v.low)
set.seed(8275591)
wordcloud(words = d.low$word, freq = d.low$freq, min.freq = 1,
max.words=50, random.order=FALSE, rot.per=0.35,
colors=brewer.pal(8, "Dark2"))
text.low <- readLines(file.choose())
doc.low <- Corpus(VectorSource(text.low))
# inspect(doc.low)
toSpace <- content_transformer(function (x , pattern ) gsub(pattern, " ", x))
doc.low <- tm_map(doc.low, toSpace, "/")
doc.low <- tm_map(doc.low, toSpace, "@")
doc.low <- tm_map(doc.low, toSpace, "\\|")
# Convert the text to lower case
doc.low <- tm_map(doc.low, content_transformer(tolower))
# Remove numbers
doc.low <- tm_map(doc.low, removeNumbers)
# Remove english common stopwords
doc.low <- tm_map(doc.low, removeWords, stopwords("english"))
# Remove your own stop word
# specify your stopwords as a character vector
doc.low <- tm_map(doc.low, removeWords, c("medicare", "health", "program", "managed", "patient", "physician", "plan"))
# Remove punctuations
doc.low <- tm_map(doc.low, removePunctuation)
# Eliminate extra white spaces
doc.low <- tm_map(doc.low, stripWhitespace)
# Text stemming
doc.low <- tm_map(doc.low, stemDocument)
# specify your stopwords as a character vector
doc.low <- tm_map(doc.low, removeWords, c("manag", "physician"))
dtm.low <- TermDocumentMatrix(doc.low)
m.low <- as.matrix(dtm.low)
v.low <- sort(rowSums(m.low),decreasing=TRUE)
d.low <- data.frame(word = names(v.low),freq=v.low)
#head(d.low, 10)
set.seed(8275591)
wordcloud(words = d.low$word, freq = d.low$freq, min.freq = 1,
max.words=50, random.order=FALSE, rot.per=0.35,
colors=brewer.pal(8, "Dark2"))
doc.low <- Corpus(VectorSource(text.low))
toSpace <- content_transformer(function (x , pattern ) gsub(pattern, " ", x))
doc.low <- tm_map(doc.low, toSpace, "/")
doc.low <- tm_map(doc.low, toSpace, "@")
doc.low <- tm_map(doc.low, toSpace, "\\|")
# Convert the text to lower case
doc.low <- tm_map(doc.low, content_transformer(tolower))
# Remove numbers
doc.low <- tm_map(doc.low, removeNumbers)
# Remove english common stopwords
doc.low <- tm_map(doc.low, removeWords, stopwords("english"))
# Remove your own stop word
doc.low <- tm_map(doc.low, removePunctuation)
# Eliminate extra white spaces
doc.low <- tm_map(doc.low, stripWhitespace)
dtm.low <- TermDocumentMatrix(doc.low)
m.low <- as.matrix(dtm.low)
v.low <- sort(rowSums(m.low),decreasing=TRUE)
d.low <- data.frame(word = names(v.low),freq=v.low)
wordcloud(words = d.low$word, freq = d.low$freq, min.freq = 1,
max.words=50, random.order=FALSE, rot.per=0.35,
colors=brewer.pal(8, "Dark2"))
library(ggplot2)
install.packages("ggridges")
library(ggridges)
theme_set(theme_ridges())
ggplot(iris, aes(x = Sepal.Length, y = Species)) +
geom_density_ridges(aes(fill = Species)) +
scale_fill_manual(values = c("#00AFBB", "#E7B800", "#FC4E07"))
install.packages("ggpubr")
library(ggpubr)
a <- ggplot(wdata, aes(x = weight))
install.packages("dplyr")
set.seed(1234)
wdata = data.frame(
sex = factor(rep(c("F", "M"), each=200)),
weight = c(rnorm(200, 55), rnorm(200, 58))
)
head(wdata, 4)
mu <- wdata %>%
group_by(sex) %>%
summarise(grp.mean = mean(weight))
mu
mu <- wdata %>%
group_by(sex) %>%
summarize(grp.mean = mean(weight))
mu
a <- ggplot(wdata, aes(x = weight))
a + geom_density() +
geom_vline(aes(xintercept = mean(weight)),
linetype = "dashed", size = 0.6)
ggdensity(wdata, x = "weight",
add = "mean", rug = TRUE,
color = "sex", fill = "sex",
palette = c("#0073C2FF", "#FC4E07"))
theme_set(theme_ridges())
ggplot(iris, aes(x = Sepal.Length, y = Species))
a <- ggplot(iris, aes(x = Sepal.Length, y = Species))
a + geom_density_ridges(aes(fill = Species))
ggplot(iris, aes(x = Sepal.Length, y = Species)) +
geom_density_ridges(scale = 0.9)
ggplot(
lincoln_weather,
aes(x = `Mean Temperature [F]`, y = `Month`)
) +
geom_density_ridges_gradient(
aes(fill = ..x..), scale = 3, size = 0.3
) +
scale_fill_gradientn(
colours = c("#0D0887FF", "#CC4678FF", "#F0F921FF"),
name = "Temp. [F]"
)+
labs(title = 'Temperatures in Lincoln NE')
browseVignettes("ggridges")
install.packages("viridis")
library(viridis)
ggplot(lincoln_weather, aes(x = `Mean Temperature [F]`, y = `Month`, fill = ..x..)) +
geom_density_ridges_gradient(scale = 3, rel_min_height = 0.01, gradient_lwd = 1.) +
scale_x_continuous(expand = c(0.01, 0)) +
scale_y_discrete(expand = c(0.01, 0)) +
scale_fill_viridis(name = "Temp. [F]", option = "C") +
labs(
title = 'Temperatures in Lincoln NE',
subtitle = 'Mean temperatures (Fahrenheit) by month for 2016\nData: Original CSV from the Weather Underground'
) +
theme_ridges(font_size = 13, grid = TRUE) + theme(axis.title.y = element_blank())
install.packages("DAAG")
library(DAAG) # for ais dataset
ais$sport <- factor(
ais$sport,
levels = c("B_Ball", "Field", "Gym", "Netball", "Row", "Swim", "T_400m", "T_Sprnt", "Tennis", "W_Polo"),
labels = c("Basketball", "Field", "Gym", "Netball", "Row", "Swim", "Track 400m", "Track Sprint", "Tennis", "Water Polo")
)
ggplot(ais, aes(x=ht, y=sport, color=sex, point_color=sex, fill=sex)) +
geom_density_ridges(
jittered_points=TRUE, scale = .95, rel_min_height = .01,
point_shape = "|", point_size = 3, size = 0.25,
position = position_points_jitter(height = 0)
) +
scale_y_discrete(expand = c(.01, 0)) +
scale_x_continuous(expand = c(0, 0), name = "height [cm]") +
scale_fill_manual(values = c("#D55E0050", "#0072B250"), labels = c("female", "male")) +
scale_color_manual(values = c("#D55E00", "#0072B2"), guide = "none") +
scale_discrete_manual("point_color", values = c("#D55E00", "#0072B2"), guide = "none") +
guides(fill = guide_legend(
override.aes = list(
fill = c("#D55E00A0", "#0072B2A0"),
color = NA, point_color = NA))
) +
ggtitle("Height in Australian athletes") +
theme_ridges(center = TRUE)
library(ggplot2)
library(ggridges)
library(ggpubr)
library("ggplot2", lib.loc="~/R/win-library/3.4")
library("ggpubr", lib.loc="~/R/win-library/3.4")
library("ggridges", lib.loc="~/R/win-library/3.4")
install.packages(c("arm", "assertthat", "backports", "bayesplot", "BH", "bindr", "bindrcpp", "broom", "Cairo", "callr", "caTools", "cli", "coda", "colorspace", "colourpicker", "curl", "data.table", "DBI", "dbplyr", "devtools", "digest", "DT", "dygraphs", "ellipsis", "evaluate", "forcats", "formatR", "ggplot2", "git2r", "gridExtra", "gtable", "gtools", "haven", "hexbin", "highr", "hms", "htmlwidgets", "httpuv", "httr", "igraph", "inline", "irlba", "jsonlite", "knitr", "lazyeval", "lme4", "loo", "maps", "markdown", "matrixStats", "mcmc", "MCMCpack", "mime", "miniUI", "modelr", "munsell", "nloptr", "NLP", "openssl", "packrat", "pkgconfig", "PKI", "plotly", "psych", "purrr", "quantreg", "R6", "RcppEigen", "RCurl", "readr", "readstata13", "readxl", "reprex", "reshape2", "RItools", "RJSONIO", "rmarkdown", "rsconnect", "rstan", "rstantools", "rstudioapi", "Rttf2pt1", "RUnit", "rvest", "scales", "shiny", "shinyjs", "shinystan", "shinythemes", "slam", "SnowballC", "sourcetools", "StanHeaders", "stringi", "stringr", "testthat", "tidyr", "tm", "utf8", "vctrs", "vioplot", "wordcloud", "XML", "xml2", "xtable", "xts", "yaml", "zoo"))
library(ggplot2)
library(ggridges)
library(ggpubr)
theme_set(theme_ridges())
library(viridis)
ggplot(lincoln_weather, aes(x = `Mean Temperature [F]`, y = `Month`, fill = ..x..)) +
geom_density_ridges_gradient(scale = 3, rel_min_height = 0.01, gradient_lwd = 1.) +
scale_x_continuous(expand = c(0.01, 0)) +
scale_y_discrete(expand = c(0.01, 0)) +
scale_fill_viridis(name = "Temp. [F]", option = "C") +
labs(
title = 'Temperatures in Lincoln NE',
subtitle = 'Mean temperatures (Fahrenheit) by month for 2016\nData: Original CSV from the Weather Underground'
) +
theme_ridges(font_size = 13, grid = TRUE) + theme(axis.title.y = element_blank())
library(DAAG) # for ais dataset
ais$sport <- factor(
ais$sport,
levels = c("B_Ball", "Field", "Gym", "Netball", "Row", "Swim", "T_400m", "T_Sprnt", "Tennis", "W_Polo"),
labels = c("Basketball", "Field", "Gym", "Netball", "Row", "Swim", "Track 400m", "Track Sprint", "Tennis", "Water Polo")
)
ggplot(ais, aes(x=ht, y=sport, color=sex, point_color=sex, fill=sex)) +
geom_density_ridges(
jittered_points=TRUE, scale = .95, rel_min_height = .01,
point_shape = "|", point_size = 3, size = 0.25,
position = position_points_jitter(height = 0)
) +
scale_y_discrete(expand = c(.01, 0)) +
scale_x_continuous(expand = c(0, 0), name = "height [cm]") +
scale_fill_manual(values = c("#D55E0050", "#0072B250"), labels = c("female", "male")) +
scale_color_manual(values = c("#D55E00", "#0072B2"), guide = "none") +
scale_discrete_manual("point_color", values = c("#D55E00", "#0072B2"), guide = "none") +
guides(fill = guide_legend(
override.aes = list(
fill = c("#D55E00A0", "#0072B2A0"),
color = NA, point_color = NA))
) +
ggtitle("Height in Australian athletes") +
theme_ridges(center = TRUE)
ggplot(ais, aes(x=ht, y=sport)) + #, color=sex, point_color=sex, fill=sex)) +
geom_density_ridges(
jittered_points=TRUE, scale = .95, rel_min_height = .01,
point_shape = "|", point_size = 3, size = 0.25,
position = position_points_jitter(height = 0)
) +
scale_y_discrete(expand = c(.01, 0)) +
scale_x_continuous(expand = c(0, 0), name = "height [cm]") +
#scale_fill_manual(values = c("#D55E0050", "#0072B250"), labels = c("female", "male")) +
#scale_color_manual(values = c("#D55E00", "#0072B2"), guide = "none") +
#scale_discrete_manual("point_color", values = c("#D55E00", "#0072B2"), guide = "none") +
#guides(fill = guide_legend(
# override.aes = list(
#  fill = c("#D55E00A0", "#0072B2A0"),
#  color = NA, point_color = NA))
#) +
ggtitle("Height in Australian athletes") +
theme_ridges(center = TRUE)
ggplot(ais, aes(x=ht, y=sport)) + #, color=sex, point_color=sex, fill=sex)) +
geom_density_ridges(
jittered_points=TRUE, scale = .95, rel_min_height = .01,
point_shape = "|", point_size = 3, size = 0.25,
position = position_points_jitter(height = 0)
) +
scale_y_discrete(expand = c(.01, 0)) +
scale_x_continuous(expand = c(0, 0), name = "height [cm]") +
scale_fill_manual(values = c("#D55E0050")) + #, "#0072B250"), labels = c("female", "male")) +
scale_color_manual(values = c("#D55E00", guide = "none")) +  # , "#0072B2"),
#scale_discrete_manual("point_color", values = c("#D55E00", "#0072B2"), guide = "none") +
#guides(fill = guide_legend(
# override.aes = list(
#  fill = c("#D55E00A0", "#0072B2A0"),
#  color = NA, point_color = NA))
#) +
ggtitle("Height in Australian athletes") +
theme_ridges(center = TRUE)
ggplot(ais, aes(x=ht, y=sport, color=sport, point_color=sport, fill=sport)) +
geom_density_ridges(
jittered_points=TRUE, scale = .95, rel_min_height = .01,
point_shape = "|", point_size = 3, size = 0.25,
position = position_points_jitter(height = 0)
) +
scale_y_discrete(expand = c(.01, 0)) +
scale_x_continuous(expand = c(0, 0), name = "height [cm]") +
scale_fill_manual(values = c("#D55E0050")) + #, "#0072B250"), labels = c("female", "male")) +
scale_color_manual(values = c("#D55E00", guide = "none")) +  # , "#0072B2"),
#scale_discrete_manual("point_color", values = c("#D55E00", "#0072B2"), guide = "none") +
#guides(fill = guide_legend(
# override.aes = list(
#  fill = c("#D55E00A0", "#0072B2A0"),
#  color = NA, point_color = NA))
#) +
ggtitle("Height in Australian athletes") +
theme_ridges(center = TRUE)
ggplot(ais, aes(x=ht, y=sport, color=sport, point_color=sport, fill=sport)) +
geom_density_ridges(
jittered_points=TRUE, scale = .95, rel_min_height = .01,
point_shape = "|", point_size = 3, size = 0.25,
position = position_points_jitter(height = 0)
) +
scale_y_discrete(expand = c(.01, 0)) +
scale_x_continuous(expand = c(0, 0), name = "height [cm]") +
#scale_fill_manual(values = c("#D55E0050")) + #, "#0072B250"), labels = c("female", "male")) +
#scale_color_manual(values = c("#D55E00", guide = "none")) +  # , "#0072B2"),
#scale_discrete_manual("point_color", values = c("#D55E00", "#0072B2"), guide = "none") +
#guides(fill = guide_legend(
# override.aes = list(
#  fill = c("#D55E00A0", "#0072B2A0"),
#  color = NA, point_color = NA))
#) +
ggtitle("Height in Australian athletes") +
theme_ridges(center = TRUE)
ggplot(ais, aes(x=ht, y=sport, color=sport, point_color=sport, fill=sport)) +
geom_density_ridges(
jittered_points=TRUE, scale = .95, rel_min_height = .01,
point_shape = "|", point_size = 3, size = 0.25,
position = position_points_jitter(height = 0)
) +
scale_y_discrete(expand = c(.01, 0)) +
scale_x_continuous(expand = c(0, 0), name = "height [cm]") +
#scale_fill_manual(values = c("#D55E0050")) + #, "#0072B250"), labels = c("female", "male")) +
#scale_color_manual(values = c("#D55E00", guide = "none")) +  # , "#0072B2"),
#scale_discrete_manual("point_color", values = c("#D55E00", "#0072B2"), guide = "none") +
#guides(fill = guide_legend(
# override.aes = list(
#  fill = c("#D55E00A0", "#0072B2A0"),
#  color = NA, point_color = NA))
#) +
ggtitle("Height in Australian athletes") +
theme_ridges(center = TRUE) +
theme(legend.position = "none")
ggplot(ais, aes(x=ht, y=sport, color=sport, point_color=sport, fill=sport)) +
geom_density_ridges(
jittered_points=TRUE, scale = .95, rel_min_height = .01,
point_shape = "|", point_size = 3, size = 0.25,
position = position_points_jitter(height = 0)
) +
scale_y_discrete(expand = c(.01, 0), name = "Sport") +
scale_x_continuous(expand = c(0, 0), name = "Height [cm]") +
#scale_fill_manual(values = c("#D55E0050")) + #, "#0072B250"), labels = c("female", "male")) +
#scale_color_manual(values = c("#D55E00", guide = "none")) +  # , "#0072B2"),
#scale_discrete_manual("point_color", values = c("#D55E00", "#0072B2"), guide = "none") +
#guides(fill = guide_legend(
# override.aes = list(
#  fill = c("#D55E00A0", "#0072B2A0"),
#  color = NA, point_color = NA))
#) +
ggtitle("Height in Australian athletes") +
theme_ridges(center = TRUE) +
theme(legend.position = "none")
rm(ais)
library(DAAG) # for ais dataset
library(mvtnorm)
library(arm)
library(BRugs)
library(R2OpenBUGS)
library(coda)
library(car)
library(foreign)
library(vioplot)
setwd("~/../Dropbox/iREDS/Data/Analysis/scales/")
# Read in OpenBUGS results and create figure
setwd("~/../Dropbox/iREDS/Data/Analysis/scales/S1")
coda.data<-read.openbugs(stem="")
results.S1<-as.data.frame(rbind(coda.data[[1]], coda.data[[2]], coda.data[[3]]))
setwd("~/../Dropbox/iREDS/Data/Analysis/scales/S2")
coda.data<-read.openbugs(stem="")
results.S2<-as.data.frame(rbind(coda.data[[1]], coda.data[[2]], coda.data[[3]]))
setwd("~/../Dropbox/iREDS/Data/Analysis/scales/S3")
coda.data<-read.openbugs(stem="")
results.S3<-as.data.frame(rbind(coda.data[[1]], coda.data[[2]], coda.data[[3]]))
setwd("~/../Dropbox/iREDS/Data/Analysis/scales/S5")
coda.data<-read.openbugs(stem="")
results.S5<-as.data.frame(rbind(coda.data[[1]], coda.data[[2]], coda.data[[3]]))
setwd("~/../Dropbox/iREDS/Data/Analysis/scales/S6")
coda.data<-read.openbugs(stem="")
results.S6<-as.data.frame(rbind(coda.data[[1]], coda.data[[2]], coda.data[[3]]))
setwd("~/../Dropbox/iREDS/Data/Analysis/scales/S8")
coda.data<-read.openbugs(stem="")
results.S8<-as.data.frame(rbind(coda.data[[1]], coda.data[[2]], coda.data[[3]]))
setwd("~/../Dropbox/iREDS/Data/Analysis/scales/")
# extract treatment effect estimates and standardize for Cohen's D
std.deltatheta<-c(0.86, 1.17, 1.33, 1.06, 1.16, 1.17)
alpha<- as.data.frame(cbind(results.S1$S1.alpha1/std.deltatheta[1], results.S2$S2.alpha1/std.deltatheta[2], results.S3$S3.alpha1/std.deltatheta[3],
results.S5$S5.alpha1/std.deltatheta[4], results.S6$S6.alpha1/std.deltatheta[5], results.S8$S8.alpha1/std.deltatheta[6]))
names(alpha)<-c("S1.alpha1", "S2.alpha1", "S3.alpha1", "S5.alpha1", "S6.alpha1", "S8.alpha1")
nrows<-length(alpha[,1])
ncols<-6 # this is the number of rows in the figure
figdata<-as.data.frame(matrix(rep(NA, nrows*ncols*2), nrow = nrows*ncols, ncol=2))
for (j in 1:ncols) {
for (i in 1:nrows) {
if (j==1) {
figdata[i+5*nrows,1] <- alpha$S1.alpha1[i]
figdata[i+5*nrows,2] <- j}
if (j==2) {
figdata[i+4*nrows,1] <- alpha$S2.alpha1[i]
figdata[i+4*nrows,2] <- j}
if (j==3) {
figdata[i+3*nrows,1] <- alpha$S3.alpha1[i]
figdata[i+3*nrows,2] <- j}
if (j==4) {
figdata[i+2*nrows,1] <- alpha$S5.alpha1[i]
figdata[i+2*nrows,2] <- j}
if (j==5) {
figdata[i+1*nrows,1] <- alpha$S6.alpha1[i]
figdata[i+1*nrows,2] <- j}
if (j==6) {
figdata[i,1] <- alpha$S8.alpha1[i]
figdata[i,2] <- j}
}
}
figdata[,2] <- factor(
figdata[,2],
levels = c("1", "2", "3", "4", "5", "6"),
labels = c("Preserve Replication Materials", "Reasons for Data Management Policy", "Reasons for Authorship Policy",
"Lab Disagreement", "Respectful Discussion", "Relevance of Ethics Discourse")
)
library(ggplot2)
library(ggridges)
library(ggpubr)
library(viridis)
theme_set(theme_ridges())
## USE THIS ONE -- THIS IS THE VERSION IN THE PAPER!
ggplot(figdata, aes(x=figdata[,1], y=figdata[,2], fill=0.5 - abs(0.5-..ecdf..))) +
stat_density_ridges(geom = "density_ridges_gradient", scale=0.9, calc_ecdf = TRUE) +
scale_fill_viridis(name = "Density", direction = -1) +
labs(
title = 'Treatment Effect Estimates',
subtitle = 'Cohen\'s D',
x = "Posterior Distribution"
) +
theme_ridges(font_size = 13, grid = TRUE) + theme(axis.title.y = element_blank())
## USE THIS ONE -- THIS IS THE VERSION IN THE PAPER!
ggplot(figdata, aes(x=figdata[,1], y=figdata[,2], fill=0.5 - abs(0.5-..ecdf..))) +
stat_density_ridges(geom = "density_ridges_gradient", scale=0.9, calc_ecdf = TRUE) +
scale_fill_viridis(name = "Prob(Tail)", direction = -1) +
labs(
title = 'Treatment Effect Estimates',
subtitle = 'Cohen\'s D',
x = "Posterior Distribution"
) +
theme_ridges(font_size = 13, grid = TRUE) + theme(axis.title.y = element_blank())
clear(list=ls(0))
rm(list=ls())
coda.data<-read.openbugs(stem="")
results<-as.data.frame(rbind(coda.data[[1]], coda.data[[2]], coda.data[[3]]))
nrows<-length(results[,1])
ncols<-3 # this is the number of rows in the figure
figdata<-as.data.frame(matrix(rep(NA, nrows*ncols*2), nrow = nrows*ncols, ncol=2))
for (j in 1:ncols) {
for (i in 1:nrows) {
if (j==3) {
figdata[i+2*nrows,1] <- results$S1.beta.2[i]
figdata[i+2*nrows,2] <- j}
if (j==2) {
figdata[i+nrows,1] <- results$S2.beta.2.2[i]
figdata[i+nrows,2] <- j}
if (j==1) {
figdata[i,1] <- results$S2.beta.2.1[i]
figdata[i,2] <- j}
}
}
figdata[,2] <- factor(
figdata[,2],
levels = c("1", "2", "3"),
labels = c("Lab Has Authorship Policy", "Lab Has Data Management Plan", "Discussion Changed Ethics Views")
)
setwd("C:/Users/Kevin/Dropbox/iREDS/Data/Analysis/single_items")
# set constants
n_respondents <- length(dataset$labid)
n_responses <- 4
n_labs <- max(dataset$labid) # not used in model
labid <- dataset$labid # not used in model
coda.data<-read.openbugs(stem="")
results<-as.data.frame(rbind(coda.data[[1]], coda.data[[2]], coda.data[[3]]))
nrows<-length(results[,1])
ncols<-3 # this is the number of rows in the figure
figdata<-as.data.frame(matrix(rep(NA, nrows*ncols*2), nrow = nrows*ncols, ncol=2))
for (j in 1:ncols) {
for (i in 1:nrows) {
if (j==3) {
figdata[i+2*nrows,1] <- results$S1.beta.2[i]
figdata[i+2*nrows,2] <- j}
if (j==2) {
figdata[i+nrows,1] <- results$S2.beta.2.2[i]
figdata[i+nrows,2] <- j}
if (j==1) {
figdata[i,1] <- results$S2.beta.2.1[i]
figdata[i,2] <- j}
}
}
figdata[,2] <- factor(
figdata[,2],
levels = c("1", "2", "3"),
labels = c("Lab Has Authorship Policy", "Lab Has Data Management Plan", "Discussion Changed Ethics Views")
)
library(ggplot2)
library(ggridges)
library(ggpubr)
library(viridis)
theme_set(theme_ridges())
## USE THIS ONE -- THIS IS THE VERSION IN THE PAPER!
ggplot(figdata, aes(x=figdata[,1], y=figdata[,2], fill=0.5 - abs(0.5-..ecdf..))) +
stat_density_ridges(geom = "density_ridges_gradient", scale=0.9, calc_ecdf = TRUE) +
scale_fill_viridis(name = "Density", direction = -1) +
labs(
title = 'Treatment Effect Estimates',
subtitle = 'Log Odds Scale',
x = "Posterior Distribution"
) +
theme_ridges(font_size = 13, grid = TRUE) + theme(axis.title.y = element_blank())
## USE THIS ONE -- THIS IS THE VERSION IN THE PAPER!
ggplot(figdata, aes(x=figdata[,1], y=figdata[,2], fill=0.5 - abs(0.5-..ecdf..))) +
stat_density_ridges(geom = "density_ridges_gradient", scale=0.9, calc_ecdf = TRUE) +
scale_fill_viridis(name = "Prob(Tail)", direction = -1) +
labs(
title = 'Treatment Effect Estimates',
subtitle = 'Log Odds Scale',
x = "Posterior Distribution"
) +
theme_ridges(font_size = 13, grid = TRUE) + theme(axis.title.y = element_blank())
